<?php

global $CFG;
require_once($CFG->libdir.'/formslib.php');

class ext_rssfeed_edit_form extends moodleform {

	function definition() {

		$mform    =& $this->_form;

//-------------------------------------------------------------------------------
        // Add General box
        $mform->addElement('header', 'general', get_string('general', 'form'));

        // Add RSS feed address text box
        $mform->addElement('text', 'word', get_string('word', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'));
        $mform->setType('word', PARAM_TEXT);
        $mform->addRule('word', null, 'required', null, 'client');
        $mform->setHelpButton('word', array('word', get_string('word', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 'resourcepage_rssfeed'));

        // Add numberoflinks dropdown
        $options = array();
        $options['0'] = 'unlimited';
        for ($i = 1; $i < 21; $i++) {
            $options[$i] = $i;
        }
        $mform->addElement('select', 'numberoflinks', get_string('numberoflinks', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), $options);
        $mform->setDefault('numberoflinks', 0);
        $mform->setHelpButton('numberoflinks', array('numberoflinks', get_string('numberoflinks', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 'resourcepage_rssfeed'));

        // Add feedupdates frequency radio buttons
        $radio = array();
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('never', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 0);
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('1hour', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 1);
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('4hours', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 4);
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('12hours', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 12);
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('1day', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 24);
        $radio[] = &MoodleQuickForm::createElement('radio', 'feedupdates', null, get_string('1week', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 168);
        $mform->addGroup($radio, 'feedupdates',  get_string('feedupdates', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), ' ', false);
        $mform->setHelpButton('feedupdates', array('feedupdates', get_string('feedupdates', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 'resourcepage_rssfeed'));
        $mform->setDefault('feedupdates', 24);

        // Add includetitle no/yes dropdown
        $mform->addElement('selectyesno', 'includetitle', get_string('includetitle', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'));
        $mform->setDefault('includetitle', 1);
        $mform->setHelpButton('includetitle', array('includetitle', get_string('includetitle', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 'resourcepage_rssfeed'));

        // Add hidden elements
        $mform->addElement('hidden', 'id', null);
        $mform->addElement('hidden', 'containerid', null);
        $mform->addElement('hidden', 'coursemodule', null);
        $mform->addElement('hidden', 'extension', null);
        $mform->addElement('hidden', 'scrollpos', null);

//-------------------------------------------------------------------------------
        // Add Save Changes and Cancel buttons
        $this->add_action_buttons(false);
	}
}
?>